package cn.edu.gzhu.workOrderManagement.enumeration;

import lombok.Getter;

import java.util.Objects;


public enum WorkOrderPriorityEnum {

    Low(1,"低优先"),
    Medium(2,"中优先"),
    High(3,"高优先"),
    Urgent(4,"最高优先");

    @Getter
    private  Integer priority;

    @Getter
    private  String description;
   WorkOrderPriorityEnum(Integer priority, String description) {
        this.priority = priority;
        this.description = description;
   }

   public static WorkOrderPriorityEnum value2Object(Integer priority ){
       for (WorkOrderPriorityEnum workOrderPriorityEnum : WorkOrderPriorityEnum.values()) {
           if (Objects.equals(workOrderPriorityEnum.getPriority(), priority)) {
               return workOrderPriorityEnum;
           }
       }
       throw new IllegalArgumentException("不合法的优先等级: " + priority + "。");
   }
}
